home *** CD-ROM | disk | FTP | other *** search
- PROGRAM ProcParmDemo;
- TYPE
- BArray = ARRAY[0..1] OF Byte;
- VAR
- Offsets : ARRAY[1..4] OF Integer;
- N : Integer;
-
- PROCEDURE first(X : Integer);
- BEGIN WriteLn(X, ' The first!'); END;
-
- PROCEDURE second(X : Integer);
- BEGIN WriteLn(X, ' The second!'); END;
-
- PROCEDURE third(B : Barray);
- BEGIN WriteLn(B[1]:3, B[0]:3, ' The third!'); END;
-
- PROCEDURE fourth(X : Integer);
- BEGIN WriteLn(X, ' The fourth!'); END;
-
- PROCEDURE dummy(X : Integer);
- { Procedure DoCall modifies the machine level code
- of this procedure. }
- BEGIN
- END;
-
- PROCEDURE Init; { Initialize the Offset array }
- BEGIN
- Offsets[1] := Ofs(first) - Ofs(dummy);
- Offsets[2] := Ofs(second) - Ofs(dummy);
- Offsets[3] := Ofs(third) - Ofs(dummy);
- Offsets[4] := Ofs(fourth) - Ofs(dummy);
- END;
-
- PROCEDURE docall(I : Integer);
- { Transfer control to subroutine number I }
- BEGIN
- MemW[CSeg:Ofs(Dummy)+5] := Offsets[I];
- dummy(I*100);
- END;
-
- BEGIN { main }
- Init;
- FOR N := 1 TO 4 DO docall(N);
- END.